x86/hvm: fix saved pmtimer and hpet values
authorKouya Shimura <kouya@jp.fujitsu.com>
Fri, 11 Sep 2015 14:24:56 +0000 (16:24 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 11 Sep 2015 14:24:56 +0000 (16:24 +0200)
commit244582a01dcb49fa30083725964a066937cc94f2
treea589e462835bf3c85c095ce7db944133afd737ad
parent93f5194e72708776783f2d34894c9b42031e116e
x86/hvm: fix saved pmtimer and hpet values

The ACPI PM timer is sometimes broken on live migration.
Since vcpu->arch.hvm_vcpu.guest_time is always zero in other than
"delay for missed ticks mode". Even in "delay for missed ticks mode",
vcpu's guest_time field is not valid (i.e. zero) when
the state of vcpu is "blocked". (see pt_save_timer function)

The original author (Tim Deegan) of pmtimer_save() must have intended
that it saves the last scheduled time of the vcpu. Unfortunately it was
already implied this bug. FYI, there is no other timer mode than
"delay for missed ticks mode" then.

For consistency with HPET, pmtimer_save() should refer hvm_get_guest_time()
to update the counter as well as hpet_save() does.

Without this patch, the clock of windows server 2012R2 without HPET
might leap forward several minutes on live migration.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Retain use of ->arch.hvm_vcpu.guest_time when non-zero. Do the inverse
adjustment for vHPET.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Kouya Shimura <kouya@jp.fujitsu.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/hpet.c
xen/arch/x86/hvm/pmtimer.c